package com.xiaoxin.smartbi.bizmq;

import com.rabbitmq.client.Channel;
import com.xiaoxin.smartbi.common.ErrorCode;
import com.xiaoxin.smartbi.exception.BusinessException;
import com.xiaoxin.smartbi.manager.AiManager;
import com.xiaoxin.smartbi.model.entity.Chart;
import com.xiaoxin.smartbi.service.ChartService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
public class MessageConsumer {

    @Resource
    private AiManager aiManager;

    @Resource
    private ChartService chartService;

    @SneakyThrows
    @RabbitListener(queues = {"code_copy_queue"},ackMode = "MANUAL")
    public void receiveMessage(String message, Channel channel,@Header(AmqpHeaders.DELIVERY_TAG) long deliverTag){
        log.info("message={}",message);
        channel.basicAck(deliverTag,false);
    }
}
